Other Protocols
The following protocols are available globally.
-
A delegate that must be provided when opening a change stream for full events. The methods called by this delegate will be called whenever the stream receives an event or encounters an error. To implement a class conforming to this protocol, be sure to add a typealias for the type of BSON documents that the delegate will react to. In most cases, this will be
Document
, but if you have specified your own Codable type, specify it instead.
See morepublic class MyNormalDelegate: ChangeStreamDelegate { typealias DocumentT = Document public func didReceive(event: ChangeEvent<Document>) { // react to events } // ...other method implementations } public class MyCustomDelegate: ChangeStreamDelegate { typealias DocumentT = MyCustomType public func didReceive(event: ChangeEvent<MyCustomType>) { // react to events } // ...other method implementations }
Declaration
Swift
public protocol ChangeStreamDelegate : AnyObject
-
A delegate that must be provided when opening a change stream for compact events. The methods called by this delegate will be called whenever the stream receives an event or encounters an error. To implement a class conforming to this protocol, be sure to add a typealias for the type of BSON documents that the delegate will react to. In most cases, this will be
Document
, but if you have specified your own Codable type, specify it instead.
See morepublic class MyNormalDelegate: CompactChangeStreamDelegate { typealias DocumentT = Document public func didReceive(event: CompactChangeEvent<Document>) { // react to events } // ...other method implementations } public class MyCustomDelegate: CompactChangeStreamDelegate { typealias DocumentT = MyCustomType public func didReceive(event: CompactChangeEvent<MyCustomType>) { // react to events } // ...other method implementations }
Declaration
Swift
public protocol CompactChangeStreamDelegate : AnyObject